//会员价值体系
define(function(require){
	var $=require("jq");
	var SelectPage = require("pz_select_page_old.js");
	recommendUserList();
//	shareList();
	function recommendUserList() {
		$.ajax({
			type : "get",
			async : false,
			url : "/vipCenter/getUserFameInfo.do",
			dataType : "json",
			success : function(ret) {
//				console.log(ret);
//				var rPoints = ret['pointsCount'];
//				var rFameValue = ret['fameCount'];
//				var info = "共奖励<em>"
//						+ rFameValue + "名望</em>";
//				$("#rinfo").html(info);
				var totalPages = ret['totalPages'];
				var htmlContent = "";
				var data = ret.fameBooks;
				if(data == null || data ==""){
					htmlContent = "<tr><td colspan='4'>暂时没有名望值信息！</td></tr>";
					$("#getPage1").hide();
				}
				$.each(data, function(index, item){
					htmlContent += "<tr><td>" + item.fameTypeName
					+ "</td><td>" + item.value
					+ "</td><td>"
					+ item.createTime + "</td><td>"
					+ item.state + "</td></tr>";
				})
				$("#recommendInfo").html(htmlContent);

				var j_SelectPage1 = $(".J_SelectPage").eq(0).attr(
						"data-total-page", totalPages), insertBox1 = $("#recommendInfo");
				//创建一个分页
				var selectPage1 = new SelectPage(
						{
							pageNode : j_SelectPage1,
							insertBox : insertBox1,
							pageUrl : "/vipCenter/getUserFameInfo.do"
						});

			}
		});
	}

	function shareList() {
		$.ajax({
			type : "get",
			async : true,
			url : "/vipCenter/shareList.do",
			dataType : "json",
			success : function(ret) {
				var rPoints = ret['pointsCount'];
				var rFameValue = ret['fameCount'];
				var sInfo = "共奖励<em>"+ rFameValue
						+ "名望</em>";
				$("#sInfo").html(sInfo);
				var totalPages = ret['totalPages'];
				var htmlContent = "";
				var data = ret['items'];
				if(data == null || data ==""){
					htmlContent = "<tr><td colspan='4' style='text-align:center;'>暂时没有分享信息！</td></tr>";
					$("#getPage2").hide();
				}
				for ( var i = 0; i < ret['items'].length; i++) {
					var pro = data[i];
					htmlContent += "<tr><td>" + pro['title'] + "</td><td>"
							+ pro['message'] + "</td><td><em>"
							+ pro['fameValue'] + "</em></td><td>"
							+ pro['createDate'] + "</td></tr>";
				}
				$("#shareInfo").html(htmlContent);
				//alert(totalPages);
				var j_SelectPage2 = $(".J_SelectPage").eq(1).attr(
						"data-total-page", totalPages),
				//alert();
				insertBox2 = $("#shareInfo");
				//创建一个分页
				var selectPage2 = new SelectPage({
					pageNode : j_SelectPage2,
					insertBox : insertBox2,
					pageUrl : "/vipCenter/shareList.do"
				});
			}
		});
	}
	
	$("#register-tips").hover(function(){
		var l=$(this).offset().left,
			t=$(this).offset().top;
		if(!this.ok){
			var img=$("<img style='position:absolute;' src='"+$(this).attr("data-load-src")+"' />");
			img.css({left:l-265,top:t+20}).appendTo(document.body);
			this.ok=img;
		}else{
			$(this.ok).show();
		};
		
	},function(){
		$(this.ok).hide();
	});
});